package com.rephilo.dubbo.service.impl;


import com.rephilo.dubbo.api.HelloService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.Random;

/**
 * 接口实现类
 *
 * @author rephilo
 */
@DubboService(version = "1.0.0")
public class HelloServiceImpl implements HelloService {

    private Random random = new Random();

    @Override
    public void methodA() {
        try {
            int time = random.nextInt(50);
            Thread.sleep(time);
            System.out.println("methodA: " + time);
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }

    @Override
    public void methodB() {
        try {
            int time = 50 + random.nextInt(50);
            Thread.sleep(time);
            System.out.println("methodB: " + time);
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }

    @Override
    public void methodC() {
        try {
            int time = 100 + random.nextInt(50);
            Thread.sleep(time);
            System.out.println("methodC: " + time);
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
